# encoding: UTF-8

class SessionsController < ApplicationController
  #skip_after_filter :store_location

  def new
  end

  def create
    user = NhanVien.find_by_MaNV(params[:session][:account])
    if user && user.authenticate(params[:session][:password])
      sign_in user
      #redirect_back_or_to root_path
      redirect_to root_path
    else
      flash.now[:error] = 'Tài khoản không tồn tại hoặc sai mật khẩu!'
      render 'new'
    end
  end

  def destroy
    sign_out
    redirect_to root_path
  end

  def deny

  end
end
